<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>冒泡排序</title>
</head>
<body>
<script>
    var arr = [1,24,54,565,655,343,20,30];
    document.write("原数组为"+arr);
    document.write("<br>");
    for (var j = 0;j<arr.length-1;j++){
    for (var i =0;i<arr.length-1-j;i++){
        if (arr[i]>arr[i+1]){
            var itep = arr[i];
            arr[i]= arr[i+1];
            arr[i+1]=itep;
        }
     }
         }
    document.write("经过冒泡排序后"+arr);
</script>
</body>
</html>